"""
读取yaml文件，并转换成规定格式，即扁平化 yaml
"""

import yaml

NEW_LIST = list()


def delayer_list(config, _k=None):
    """扁平化yaml"""
    for k, v in config.items():
        new_key = f'{_k}.{k}' if _k else k
        if isinstance(v, dict):
            delayer_list(v, new_key)
        else:
            NEW_LIST.append((new_key, v))


with open("sample.yaml", 'r') as f:
    config = yaml.load(f, yaml.FullLoader)
    delayer_list(config, _k='')


print(NEW_LIST)
